home *** CD-ROM | disk | FTP | other *** search
- Form1
- Linking/SmartFill Demo
- Form1
- Text1
- Command1
- List1
- Command2
- Demo Info
- Command3
- Cancel
- txtEntry_Change
- String2Find!
- TxtEntry
- wIndex
- LstFindEntry
- Result
- SendMessage
- GetFocus
- LB_SELECTSTRINGq
- cmdClear_Click^
- DropCombo
- AutoRedraw
- start
- LB_RESETCONTENT
- CurrentXj
- CmdClear
- CurrentY
- Height
- Totalz
- cmdOk
- cmdClearVB_Click
- whiel
- ListCount
- cmdLoad_ClickL
- AddStr
- cmdOK_Click
- LstFindEntry_ClickS
- SPEEDTYPE-
- SelStart
- List'
- SelLength|
- Cbo_Last`
- SelectionStart
- txtEntry_KeyPress
- KeyAscii
- TxtLen
- txtEntry_KeyUp
- KeyCode
- Shift
- DontSearch"
- FALSE
- txtEntry_KeyDown
- ListIndex
- Index
- LstFindIndex
- Lindexx
- STARTSPEEDTYPING
- Lscroll
- TxtEntrly1
- LoadSampleDataV
- Form_Click
- @ Form_Load
- window_
- state
- LoadSomeSampleData
- WindowState
- Txt_Text1_Change"
- Txt_Text1.
- Txt_Text1_KeyDownB
- Lst_Link1N
- Lst_Link1_Click
- Cmd_Command1_Click
- SearchString
- StartSearch;
- TxtText1_Change
- TxtText1
- TxtText1_KeyDowni
- LstLink1`
- LstLink1_Click
- List1
- List1_Click3
- Text1
- Text1_Change
- Text1_KeyDownd
- Command1_Click
- wParm
- lparamU
- NewListIndex
- StartSmartFill
- NORMAL
- KEY_BACK
- KEY_DELETE?
- KEY_PGUPI
- KEY_PGDN
- KEY_UP
- KEY_DOWN
- Text1_KeyUp
- Command2_Click
- Microsoft
- there
- product
- give[
- users
- Command3_Click
- MB_YESNO2
- ID_YESD
- MB_YESCANCEL
- IDYES
- andIf
- MB_OKCANCEL
- AText1
- sTemp
- lTemp
- characters
- SmartFill
- typed
- enough
- MB_ICONINFORMATION
- Title: LINKDEMO.FRM
- Version: 1.0
- Project: LINKDEMO.MAK
- Description: Demonstration of Linked Text/ListBoxes and SmartFill Demo '
- Author: Jack Presley
- Created: Jan 4, 1992
- Last Revision: Jan 4, 1992 23:00
- Click on "Demo Info" for more information about this demonstration.
- API Function Declarations.n
- GetFocus returns hWnd% for the control with the
- current focus. VB's hWnd% only returns a value
- for forms, not controls.d
- This function does all the work of selecting thet
- matching element in our linked list box. It will do
- much more, such as clear a listbox with one call. SeeS
- the January 1992 "Inside Visual Basic" journal forf
- more details.
- Change this value to determine when to start filling in
- text box with data from list box. If the value is 2,
- and a link exists, when the user types the 3rd character
- the remaining characters will be filled in.
- LoadSampleData
- Just some junk mail to put in our list box...
- Ralph"
- Janet"
- Lloyd"
- Thomas
- Andrew
- Anderson
- Anderman
- Beeson
- Martin
- McAngus"
- Caroline
- Joseph
- Steven
- Robert
- Sarah"
- Cindy"
- Karen"
- Dennis
- Gladys
- Form_Load
- This is explained in Text1_Change
- List1_Click
- This routine places the item which was clicked upon
- into the Text box. This in turn causes a Text1_Changen
- event to occur, which resets the focus to the linkedk
- text box.
- Text1_Change
- If certain keys are pressed we do not want to searchr
- the linked list box. 'DontSearch' is set in thet
- Text1_KeyUp procedure. See it for more info.
- Can't pass Text1.Text "ByVal" so assign it to a
- normal string variable...
- Save our position in the text box
- This is where our SmartFill will begin...
- Start our search at the beginning...w
- Set the focus to the linked list so we can geth
- it's "hWnd%" value with GetFocust
- Make the call...t
- If we found a match and we want to search and we have
- typed enough characters to start SmartFill...
- restore the insertion point and selection...t
- we had to change it to the list box, remember?!
- Command1_Click
- You did not select anyone.
- Link Demonstration
- Nothing in the text box, leave...
- We've hit the list
- Test for a match...
- You have selected
- for updating.
- Link Demonstration
- Exit now to avoid next test...s
- The selection has failed both previous tests, must be
- a new guy. Do we add him/her or move on?
- is not in the list.
- Would you like to add them to the list?"
- Link Demonstration
- Add the item...
- Highlight the new guy in the text and list boxes...
- Let them start over
- Text1_KeyDown
- This routine allows the user to scroll through the list box
- while the focus is in the text box. This simulates a link.
- This routine needs to be in the KeyDown vs. KeyUp to allowl
- the user to hold a key down and scroll. You may experiment
- and replace the work KeyDown with KeyUp in the Sub statemente
- above and watch what happens when you press and hold the up
- or down arrow, or PgUp/PgDn.D
- If there is nothing in the list, leave...
- A temp variable because I'm a lazy typer...
- Determine how much to scroll with a PgUp or PgDnh
- minimum
- will use 1/10 of the total...
- If the user presses the backspace or delete key, we don't want'
- to search for a match in our linked listbox on this pass. If
- we did the search we would find a match and probably replace thea
- text he just deleted with the same text. The user could keep
- typing, but could never back up or erase the selected text. Yout
- may change the TRUE (below) to FALSE to see what happens.
- These lines do the scrolling in the list box. The "KeyCode = 0"
- statement, effectively erases the keystroke so the text box is notn
- affected.
- Don't Change anything
- Make sure the new ListIndex value is legal...
- Set the new value...s
- Command2_Click
- Define All messages first for a little faster response...
- Linked Text/List Box and SmartFill Demonstration"
- Jack Presley"
- Version 1
- January 4, 1992
- This program demonstrates two effective tools which you may use
- in your Visual Basic Applications. The first is the Linked Text "
- and List box. Although I had previously accomplished this "
- without any API calls by trapping keys, the recent article "
- 'Creating a new control--the Combo Dropdown List box' in 'Inside "
- Visual Basic' Vol. 2 No. 1 (January 1992) provided me with a "
- better and faster way to make the link.
- As the user types in the text box, a 'greater than or equal to'
- search is performed on the linked list box using whatever has
- been typed into the text box as the key. When the user presses
- OK to confirm his choice, a simple comparison of the Text box
- text and the Listbox index text will tell you if the text is in
- the list box or not. There's more...
- I use this 'modified' control regularly in my database "
- applications. I put the key field in a linked text/list box. "
- When the user makes a selection in this control I can either "
- update the form with that records data or query the user if they "
- would like to add this as a new record. I've got to admit that
- the side affect I like the most is NO SCROLL controls are on my
- forms! The linked list/text box IS the scroll bar. On small
- forms I update the form with every Link_Change. This makes "
- scrolling a little slower, but lets the user browse through the
- records. On large forms I update the form with Link_DoubleClick "
- or Command1_Click, unless the user selects a browse option. This
- is just one example of the way I put Linked Text/List boxes to "
- use. Click OK for information on SpeedFill... "
- SpeedFill is a real time saver. It uses the match found in the
- Linked List box to 'fill in' the remainder of the selection being
- made in the Linked Text box. You may change the number of
- keystrokes required to 'kick in' SpeedFill. Normally you don't
- want to start it until after the second keystroke or so.
- The way SpeedFill works is really pretty simple. When a key is
- pressed the program records how may characters are in the Text "
- box text. If a match is found in the Linked list box, that text "
- is assigned to the Text box text. Here's the magic: Assign the
- previous text length to the SelStart property and SelLength to "
- the length of the new Text box text. Everything in the new
- SUGGESTED text that was NOT typed by the user is highlighted. "
- Since Windows replaces highlighted text with the next keystroke, "
- the user can simply keep typing until a match is made or the text
- is complete. I make this an option in all my apps."
- If you use the Linked Text/List box, SpeedFill is an easy option to give your users.
- This snippet of code and unsolicited advice is free. Please feel "
- free to use it as you wish. BUT if you decide to upload it with "
- *ANY* changes, PLEASE, PLEASE remove my name and address from all the modules.
- Thanks, and good luck. "
- Jack Presley
- CIS: 70700,166 BIX: JackPresley
- Presley Computing"
- Route 4, Box 4171 Boerne, TX 78006
- (512) 755-9018
- (512) 977-0650 (FAX)
- I'm rarely on Bix and my presence on Compuserve is somewhat
- inconsistent. If you really need to get in touch, call or fax."
- P.S. I will have a new address and phone numbers February 1, 1992."
- Link Demonstration
- Link Demonstration
- SpeedFill"
- Link Demonstration
- Command3_Click
- Hopefully this isn't the end. If you improve these
- procedures, please let me and others know about it.
- Everyone needs feedback; good or bad.
- Thanks,
- Jack Presley
-